package br.edu.infnet.avaliacao.model;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "aluno", catalog = "avaliacao", uniqueConstraints = @UniqueConstraint(columnNames = "cpf"))
public class Aluno implements java.io.Serializable {

	private static final long serialVersionUID = 8323555670050685191L;
	private Integer id;
	private Usuario usuario;
	private String nome;
	private String cpf;
	private String sexo;
	private String email;
	private Set<Matricula> matriculas = new HashSet<Matricula>(0);
	private Set<FormacaoAluno> formacaoAlunos = new HashSet<FormacaoAluno>(0);

	public Aluno() {
	}

	public Aluno(Usuario usuario, String nome, String cpf, String sexo,
			String email) {
		this.usuario = usuario;
		this.nome = nome;
		this.cpf = cpf;
		this.sexo = sexo;
		this.email = email;
	}

	public Aluno(Usuario usuario, String nome, String cpf, String sexo,
			String email, Set<Matricula> matriculas,
			Set<FormacaoAluno> formacaoAlunos) {
		this.usuario = usuario;
		this.nome = nome;
		this.cpf = cpf;
		this.sexo = sexo;
		this.email = email;
		this.matriculas = matriculas;
		this.formacaoAlunos = formacaoAlunos;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "usuario_id", nullable = false)
	public Usuario getUsuario() {
		return this.usuario;
	}

	public void setUsuario(Usuario usuario) {
		this.usuario = usuario;
	}

	@Column(name = "nome", nullable = false, length = 50)
	public String getNome() {
		return this.nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	@Column(name = "cpf", nullable = false)
	public String getCpf() {
		return this.cpf;
	}

	public void setCpf(String cpf) {
		this.cpf = cpf;
	}

	@Column(name = "sexo", nullable = false, length = 1)
	public String getSexo() {
		return this.sexo;
	}

	public void setSexo(String sexo) {
		this.sexo = sexo;
	}

	@Column(name = "email", nullable = false, length = 50)
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "aluno")
	public Set<Matricula> getMatriculas() {
		return this.matriculas;
	}

	public void setMatriculas(Set<Matricula> matriculas) {
		this.matriculas = matriculas;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "aluno")
	public Set<FormacaoAluno> getFormacaoAlunos() {
		return this.formacaoAlunos;
	}

	public void setFormacaoAlunos(Set<FormacaoAluno> formacaoAlunos) {
		this.formacaoAlunos = formacaoAlunos;
	}

}
